package com.srit.forecast.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.srit.forecast.bean.SevenDays;
import com.srit.forecast.bean.SevenDaysPort;
import com.srit.forecast.bean.vo.SevenDaysVo;
import com.srit.forecast.dao.SevenDaysDao;
import com.srit.system.dao.CodeTypeDao;

@Controller
public class SevenDaysController {
	@Autowired(required = true )
	private SevenDaysDao sevendaysDao;
	@RequestMapping(value = "views/sevenDaysSaveBefore")
	public String saveBefore(ModelMap modelMap){
		SevenDaysVo sevenDaysVo = new SevenDaysVo();
		sevenDaysVo.setCityTemp1("11");
		modelMap.addAttribute(sevenDaysVo);
		return "sevenDays";
	}
	
	
	
	@RequestMapping(value = "/sevenDaysSave",method = RequestMethod.POST)
	public String save(SevenDaysVo sevenDaysVo){
		Date date = new Date();
		//得到1-7天对象进行保存，可进行梳理
		SevenDays sevenDays1 = new SevenDays();
		SevenDays sevenDays2 = new SevenDays();
		SevenDays sevenDays3 = new SevenDays();
		SevenDays sevenDays4 = new SevenDays();
		SevenDays sevenDays5 = new SevenDays();
		SevenDays sevenDays6 = new SevenDays();
		SevenDays sevenDays7 = new SevenDays();
		
		sevenDays1.setCityWeather(sevenDaysVo.getCityWeather1());
		sevenDays1.setCityTemp(sevenDaysVo.getCityTemp1());
		sevenDays1.setCreator(sevenDaysVo.getCreator());
		sevenDays1.setCollator(sevenDaysVo.getCollator());
		sevenDays1.setPubTime(date);
		sevenDays1.setReportTime(date);
		
		List<SevenDaysPort> portList1 = sevenDaysVo.getPortList1();
	
		return "sevenDays";
	}
	
	@Autowired
	private CodeTypeDao codeTypeDao;
	@RequestMapping(value="/sevenDays-form")
	public String form(ModelMap modelMap){
		modelMap.addAttribute("codeTypeList",codeTypeDao.listOnDrag());
		return "sevenDays";
	}
	
}
